<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			
			p,
			h3 {
				width: 50px;
				height: 50px;
				background: red;
				float: left;
				margin-left: 10px;
			}
		</style>
		<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
		<script type="text/javascript">
			$(function(){
				$("p").click(function(){
					//prevAll()前面所有兄弟         点击自己变蓝，前面（左边）所有兄弟变黄
//					$(this).css("background" , "blue").prevAll().css("background" , "yellow");
					
					$(this).css("background" , "blue").prevAll('.teshu').css("background" , "yellow");
					
					//next()后面一个兄弟
//					$(this).css("background" , "blue").next().css("background" , "yellow");
				});
			});
		</script>
	</head>
	<body>
		<p></p>
		<p class="teshu">teshu</p>
		<h3>h3</h3>
		<p></p>
		<p></p>
		<p class="teshu">teshu</p>
	</body>
</html>
